import 'dart:io';

import 'package:sl_doclever/sl_doclever.dart';
import 'package:test/test.dart';

void doLogic(SLDoclever doc) {
  return;
  print(doc.docDatas);
  doc.docDatas.forEach((element) {
    var objc = SLObjc(element);
    objc.toModelFiles().forEach((key, value) {
      File('/Users/sam/Desktop/doclever_2/$key').writeAsStringSync(value);
    });
    print(objc.outObjc);
  });
}

void doLogicHTTP(SLDoclever doc) async {
  var objc = SLObjcHttp(doc.docDatas);
  // objc.reuestMap.forEach((key, value) {
  //   File('/Users/sam/Desktop/doclever_2/$key').writeAsStringSync(value);
  // });

  var rac = SLDocRAC(objc);
  rac.saveToLocal('/Users/sam/Desktop/doclever_2/vm_request.json');
  rac.outMap.forEach((key, value) {
    File('/Users/sam/Desktop/doclever_2/$key').writeAsStringSync(value);
  });

  // SLObjcHttp(doc.docDatas).separateMap.forEach((key, value) {
  //   File('/Users/shanliu/Desktop/doclever_2/$key').writeAsStringSync(value);
  // });
}

void doLogicJAVA(SLDoclever doc) {
  return;
  print(doc.docDatas);
  doc.docDatas.forEach((element) {
    SLJava(element).outFiles.forEach((key, value) {
      File('/Users/sam/Desktop/doclever_2/$key').writeAsStringSync(value);
    });
  });
}

void main() {
  group('单个Params', () {
    setUp(() {
      SLDocConfig().prefix = 'SEG';
      SLDocConfig().root = 'userInfo';
      // SLDocConfig().isMap = true;
    });

    test('1 Test', () {
      var doc = SLDoclever(['./example/a.json']);
      doLogic(doc);
      doLogicHTTP(doc);
      doLogicJAVA(doc);
    });

    test('2 Test', () {
      var doc = SLDoclever(['./example/c.json']);
      doLogic(doc);
      doLogicHTTP(doc);
      doLogicJAVA(doc);
    });

    test('3 Test', () {
      var doc = SLDoclever(['./examp le/a.json', './example/a.json']);
      doLogic(doc);
      doLogicHTTP(doc);
      doLogicJAVA(doc);
    });

    test('4 Test', () {
      var doc = SLDoclever(['./example/a.json', './example/c.json']);
      doLogic(doc);
      doLogicHTTP(doc);
      doLogicJAVA(doc);
    });

    test('5 Test', () {
      var doc = SLDoclever(['/Users/shanliu/Desktop/doclever/三一自动认证.json']);
      doLogic(doc);
      doLogicHTTP(doc);
      doLogicJAVA(doc);
    });
  });
}
